package me.haoliang.akka

import akka.actor.UntypedActor
import org.slf4j.LoggerFactory

/**
  * author: planck 
  * createTime: 2016/10/31.
  */
class AkkaListener extends UntypedActor {


  val logger = LoggerFactory.getLogger(classOf[AkkaListener])

  @scala.throws[Throwable](classOf[Throwable])
  override def onReceive(message: Any) = {
    message match {
      case x: String => handleMessage(x);
      case t: Any => println(t);
    }
  }

  def handleMessage(str: String) = {
    logger.info(str)
    getSender().tell(str, getSelf())
  }
}
